<!DOCTYPE html>

<html lang="en" data-content_root="../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <title>FindBoost &mdash; CMake 4.1.1 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=a2c47e09" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css?v=4d06bd55" />
    
    <script src="../_static/documentation_options.js?v=e6a937a4"></script>
    <script src="../_static/doctools.js?v=9bcbadda"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    
    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="FindCABLE" href="FindCABLE.html" />
    <link rel="prev" title="WriteCompilerDetectionHeader" href="WriteCompilerDetectionHeader.html" />
 

  </head><body>
    <input id="sidebar-check" type="checkbox" />
    <label id="sidebar-overlay" for="sidebar-check"></label>



    <div class="related relbar1" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="FindCABLE.html" title="FindCABLE"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="WriteCompilerDetectionHeader.html" title="WriteCompilerDetectionHeader"
             accesskey="P">previous</a> |</li>
  <li>
    <label class="sidebar-toggle" for="sidebar-check"></label>
  </li>
  <li class="rootlink">
    <img src="../_static/cmake-logo-16.png" width="16" height="16" alt=""/>
    <a href="https://cmake.org/">CMake 4.1.1</a>
    <span class="reldelim1"> &#187;</span>
  </li>
  <li>
    <a href="../index.html">Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" accesskey="U">cmake-modules(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">FindBoost</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="findboost">
<span id="module:FindBoost"></span><h1>FindBoost<a class="headerlink" href="#findboost" title="Link to this heading">¶</a></h1>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.30: </span>This module is available only if policy <span class="target" id="index-0-policy:CMP0167"></span><a class="reference internal" href="../policy/CMP0167.html#policy:CMP0167" title="CMP0167"><code class="xref cmake cmake-policy docutils literal notranslate"><span class="pre">CMP0167</span></code></a> is not set to
<code class="docutils literal notranslate"><span class="pre">NEW</span></code>.  Port projects to upstream Boost's <code class="docutils literal notranslate"><span class="pre">BoostConfig.cmake</span></code> package
configuration file, for which <code class="docutils literal notranslate"><span class="pre">find_package(Boost)</span></code> now searches.</p>
</div>
<p>Find Boost include dirs and libraries</p>
<p>Use this module by invoking <span class="target" id="index-0-command:find_package"></span><a class="reference internal" href="../command/find_package.html#command:find_package" title="find_package"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">find_package()</span></code></a> with the form:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">find_package(</span><span class="nb">Boost</span>
<span class="w">  </span><span class="p">[</span><span class="nb">version</span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="no">EXACT</span><span class="p">]</span><span class="w">      </span><span class="c"># Minimum or EXACT version e.g. 1.67.0</span>
<span class="w">  </span><span class="p">[</span><span class="no">REQUIRED</span><span class="p">]</span><span class="w">             </span><span class="c"># Fail with error if Boost is not found</span>
<span class="w">  </span><span class="p">[</span><span class="no">COMPONENTS</span><span class="w"> </span><span class="nv">&lt;libs&gt;...</span><span class="p">]</span><span class="w"> </span><span class="c"># Boost libraries by their canonical name</span>
<span class="w">                         </span><span class="c"># e.g. &quot;date_time&quot; for &quot;libboost_date_time&quot;</span>
<span class="w">  </span><span class="p">[</span><span class="no">OPTIONAL_COMPONENTS</span><span class="w"> </span><span class="nv">&lt;libs&gt;...</span><span class="p">]</span>
<span class="w">                         </span><span class="c"># Optional Boost libraries by their canonical name)</span>
<span class="w">  </span><span class="nf">)</span><span class="w">                      </span><span class="c"># e.g. &quot;date_time&quot; for &quot;libboost_date_time&quot;</span>
</pre></div>
</div>
<p>This module finds headers and requested component libraries OR a CMake
package configuration file provided by a &quot;Boost CMake&quot; build.  For the
latter case skip to the <a class="reference internal" href="#boost-cmake"><span class="std std-ref">Boost CMake</span></a> section below.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.7: </span><code class="docutils literal notranslate"><span class="pre">bzip2</span></code> and <code class="docutils literal notranslate"><span class="pre">zlib</span></code> components (Windows only).</p>
</div>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.11: </span>The <code class="docutils literal notranslate"><span class="pre">OPTIONAL_COMPONENTS</span></code> option.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13: </span><code class="docutils literal notranslate"><span class="pre">stacktrace_*</span></code> components.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.19: </span><code class="docutils literal notranslate"><span class="pre">bzip2</span></code> and <code class="docutils literal notranslate"><span class="pre">zlib</span></code> components on all platforms.</p>
</div>
<section id="result-variables">
<h2>Result Variables<a class="headerlink" href="#result-variables" title="Link to this heading">¶</a></h2>
<p>This module defines the following variables:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_FOUND</span></code></dt><dd><p>True if headers and requested libraries were found.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_INCLUDE_DIRS</span></code></dt><dd><p>Boost include directories.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_LIBRARY_DIRS</span></code></dt><dd><p>Link directories for Boost libraries.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_LIBRARIES</span></code></dt><dd><p>Boost component libraries to be linked.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_&lt;COMPONENT&gt;_FOUND</span></code></dt><dd><p>True if component <code class="docutils literal notranslate"><span class="pre">&lt;COMPONENT&gt;</span></code> was found (<code class="docutils literal notranslate"><span class="pre">&lt;COMPONENT&gt;</span></code> name is upper-case).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_&lt;COMPONENT&gt;_LIBRARY</span></code></dt><dd><p>Libraries to link for component <code class="docutils literal notranslate"><span class="pre">&lt;COMPONENT&gt;</span></code> (may include
<span class="target" id="index-0-command:target_link_libraries"></span><a class="reference internal" href="../command/target_link_libraries.html#command:target_link_libraries" title="target_link_libraries"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">target_link_libraries()</span></code></a> debug/optimized keywords).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_VERSION_MACRO</span></code></dt><dd><p><code class="docutils literal notranslate"><span class="pre">BOOST_VERSION</span></code> value from <code class="docutils literal notranslate"><span class="pre">boost/version.hpp</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_VERSION_STRING</span></code></dt><dd><p>Boost version number in <code class="docutils literal notranslate"><span class="pre">X.Y.Z</span></code> format.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_VERSION</span></code></dt><dd><p>Boost version number in <code class="docutils literal notranslate"><span class="pre">X.Y.Z</span></code> format (same as <code class="docutils literal notranslate"><span class="pre">Boost_VERSION_STRING</span></code>).</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.15: </span>In previous CMake versions, this variable used the raw version string
from the Boost header (same as <code class="docutils literal notranslate"><span class="pre">Boost_VERSION_MACRO</span></code>).
See policy <span class="target" id="index-0-policy:CMP0093"></span><a class="reference internal" href="../policy/CMP0093.html#policy:CMP0093" title="CMP0093"><code class="xref cmake cmake-policy docutils literal notranslate"><span class="pre">CMP0093</span></code></a>.</p>
</div>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_LIB_VERSION</span></code></dt><dd><p>Version string appended to library filenames.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_VERSION_MAJOR</span></code>, <code class="docutils literal notranslate"><span class="pre">Boost_MAJOR_VERSION</span></code></dt><dd><p>Boost major version number (<code class="docutils literal notranslate"><span class="pre">X</span></code> in <code class="docutils literal notranslate"><span class="pre">X.Y.Z</span></code>).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_VERSION_MINOR</span></code>, <code class="docutils literal notranslate"><span class="pre">Boost_MINOR_VERSION</span></code></dt><dd><p>Boost minor version number (<code class="docutils literal notranslate"><span class="pre">Y</span></code> in <code class="docutils literal notranslate"><span class="pre">X.Y.Z</span></code>).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_VERSION_PATCH</span></code>, <code class="docutils literal notranslate"><span class="pre">Boost_SUBMINOR_VERSION</span></code></dt><dd><p>Boost subminor version number (<code class="docutils literal notranslate"><span class="pre">Z</span></code> in <code class="docutils literal notranslate"><span class="pre">X.Y.Z</span></code>).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_VERSION_COUNT</span></code></dt><dd><p>Amount of version components (3).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_LIB_DIAGNOSTIC_DEFINITIONS</span></code> (Windows-specific)</dt><dd><p>Pass to <span class="target" id="index-0-command:add_definitions"></span><a class="reference internal" href="../command/add_definitions.html#command:add_definitions" title="add_definitions"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">add_definitions()</span></code></a> to have diagnostic
information about Boost's automatic linking
displayed during compilation</p>
</dd>
</dl>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15: </span>The <code class="docutils literal notranslate"><span class="pre">Boost_VERSION_&lt;PART&gt;</span></code> variables.</p>
</div>
</section>
<section id="cache-variables">
<h2>Cache variables<a class="headerlink" href="#cache-variables" title="Link to this heading">¶</a></h2>
<p>Search results are saved persistently in CMake cache entries:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">Boost_INCLUDE_DIR</span></code></dt><dd><p>Directory containing Boost headers.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_LIBRARY_DIR_RELEASE</span></code></dt><dd><p>Directory containing release Boost libraries.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_LIBRARY_DIR_DEBUG</span></code></dt><dd><p>Directory containing debug Boost libraries.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_&lt;COMPONENT&gt;_LIBRARY_DEBUG</span></code></dt><dd><p>Component <code class="docutils literal notranslate"><span class="pre">&lt;COMPONENT&gt;</span></code> library debug variant.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_&lt;COMPONENT&gt;_LIBRARY_RELEASE</span></code></dt><dd><p>Component <code class="docutils literal notranslate"><span class="pre">&lt;COMPONENT&gt;</span></code> library release variant.</p>
</dd>
</dl>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.3: </span>Per-configuration variables <code class="docutils literal notranslate"><span class="pre">Boost_LIBRARY_DIR_RELEASE</span></code> and
<code class="docutils literal notranslate"><span class="pre">Boost_LIBRARY_DIR_DEBUG</span></code>.</p>
</div>
</section>
<section id="hints">
<h2>Hints<a class="headerlink" href="#hints" title="Link to this heading">¶</a></h2>
<p>This module reads hints about search locations from variables:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">BOOST_ROOT</span></code>, <code class="docutils literal notranslate"><span class="pre">BOOSTROOT</span></code></dt><dd><p>Preferred installation prefix.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">BOOST_INCLUDEDIR</span></code></dt><dd><p>Preferred include directory e.g. <code class="docutils literal notranslate"><span class="pre">&lt;prefix&gt;/include</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">BOOST_LIBRARYDIR</span></code></dt><dd><p>Preferred library directory e.g. <code class="docutils literal notranslate"><span class="pre">&lt;prefix&gt;/lib</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_NO_SYSTEM_PATHS</span></code></dt><dd><p>Set to <code class="docutils literal notranslate"><span class="pre">ON</span></code> to disable searching in locations not
specified by these hint variables. Default is <code class="docutils literal notranslate"><span class="pre">OFF</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_ADDITIONAL_VERSIONS</span></code></dt><dd><p>List of Boost versions not known to this module.
(Boost install locations may contain the version).</p>
</dd>
</dl>
<p>Users may set these hints or results as <code class="docutils literal notranslate"><span class="pre">CACHE</span></code> entries.  Projects
should not read these entries directly but instead use the above
result variables.  Note that some hint names start in upper-case
<code class="docutils literal notranslate"><span class="pre">BOOST</span></code>.  One may specify these as environment variables if they are
not specified as CMake variables or cache entries.</p>
<p>This module first searches for the Boost header files using the above
hint variables (excluding <code class="docutils literal notranslate"><span class="pre">BOOST_LIBRARYDIR</span></code>) and saves the result in
<code class="docutils literal notranslate"><span class="pre">Boost_INCLUDE_DIR</span></code>.  Then it searches for requested component libraries
using the above hints (excluding <code class="docutils literal notranslate"><span class="pre">BOOST_INCLUDEDIR</span></code> and
<code class="docutils literal notranslate"><span class="pre">Boost_ADDITIONAL_VERSIONS</span></code>), &quot;lib&quot; directories near <code class="docutils literal notranslate"><span class="pre">Boost_INCLUDE_DIR</span></code>,
and the library name configuration settings below.  It saves the
library directories in <code class="docutils literal notranslate"><span class="pre">Boost_LIBRARY_DIR_DEBUG</span></code> and
<code class="docutils literal notranslate"><span class="pre">Boost_LIBRARY_DIR_RELEASE</span></code> and individual library
locations in <code class="docutils literal notranslate"><span class="pre">Boost_&lt;COMPONENT&gt;_LIBRARY_DEBUG</span></code> and <code class="docutils literal notranslate"><span class="pre">Boost_&lt;COMPONENT&gt;_LIBRARY_RELEASE</span></code>.
When one changes settings used by previous searches in the same build
tree (excluding environment variables) this module discards previous
search results affected by the changes and searches again.</p>
</section>
<section id="imported-targets">
<h2>Imported Targets<a class="headerlink" href="#imported-targets" title="Link to this heading">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.5.</span></p>
</div>
<p>This module defines the following <span class="target" id="index-0-prop_tgt:IMPORTED"></span><a class="reference internal" href="../prop_tgt/IMPORTED.html#prop_tgt:IMPORTED" title="IMPORTED"><code class="xref cmake cmake-prop_tgt docutils literal notranslate"><span class="pre">IMPORTED</span></code></a> targets:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">Boost::boost</span></code></dt><dd><p>Target for header-only dependencies. (Boost include directory).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost::headers</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15: </span>Alias for <code class="docutils literal notranslate"><span class="pre">Boost::boost</span></code>.</p>
</div>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost::&lt;component&gt;</span></code></dt><dd><p>Target for specific component dependency (shared or static library);
<code class="docutils literal notranslate"><span class="pre">&lt;component&gt;</span></code> name is lower-case.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost::diagnostic_definitions</span></code></dt><dd><p>Interface target to enable diagnostic information about Boost's automatic
linking during compilation (adds <code class="docutils literal notranslate"><span class="pre">-DBOOST_LIB_DIAGNOSTIC</span></code>).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost::disable_autolinking</span></code></dt><dd><p>Interface target to disable automatic linking with MSVC
(adds <code class="docutils literal notranslate"><span class="pre">-DBOOST_ALL_NO_LIB</span></code>).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost::dynamic_linking</span></code></dt><dd><p>Interface target to enable dynamic linking with MSVC
(adds <code class="docutils literal notranslate"><span class="pre">-DBOOST_ALL_DYN_LINK</span></code>).</p>
</dd>
</dl>
<p>Implicit dependencies such as <code class="docutils literal notranslate"><span class="pre">Boost::filesystem</span></code> requiring
<code class="docutils literal notranslate"><span class="pre">Boost::system</span></code> will be automatically detected and satisfied, even
if system is not specified when using <span class="target" id="index-1-command:find_package"></span><a class="reference internal" href="../command/find_package.html#command:find_package" title="find_package"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">find_package()</span></code></a> and if
<code class="docutils literal notranslate"><span class="pre">Boost::system</span></code> is not added to <span class="target" id="index-1-command:target_link_libraries"></span><a class="reference internal" href="../command/target_link_libraries.html#command:target_link_libraries" title="target_link_libraries"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">target_link_libraries()</span></code></a>.  If using
<code class="docutils literal notranslate"><span class="pre">Boost::thread</span></code>, then <code class="docutils literal notranslate"><span class="pre">Threads::Threads</span></code> will also be added automatically.</p>
<p>It is important to note that the imported targets behave differently
than variables created by this module: multiple calls to
<span class="target" id="index-2-command:find_package"></span><a class="reference internal" href="../command/find_package.html#command:find_package" title="find_package(boost)"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">find_package(Boost)</span></code></a> in the same directory or sub-directories with
different options (e.g. static or shared) will not override the
values of the targets created by the first call.</p>
</section>
<section id="other-variables">
<h2>Other Variables<a class="headerlink" href="#other-variables" title="Link to this heading">¶</a></h2>
<p>Boost libraries come in many variants encoded in their file name.
Users or projects may tell this module which variant to find by
setting variables:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_USE_DEBUG_LIBS</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.10.</span></p>
</div>
<p>Set to <code class="docutils literal notranslate"><span class="pre">ON</span></code> or <code class="docutils literal notranslate"><span class="pre">OFF</span></code> to specify whether to search and use the debug
libraries.  Default is <code class="docutils literal notranslate"><span class="pre">ON</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_USE_RELEASE_LIBS</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.10.</span></p>
</div>
<p>Set to <code class="docutils literal notranslate"><span class="pre">ON</span></code> or <code class="docutils literal notranslate"><span class="pre">OFF</span></code> to specify whether to search and use the release
libraries.  Default is <code class="docutils literal notranslate"><span class="pre">ON</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_USE_MULTITHREADED</span></code></dt><dd><p>Set to OFF to use the non-multithreaded libraries (&quot;mt&quot; tag). Default is
<code class="docutils literal notranslate"><span class="pre">ON</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_USE_STATIC_LIBS</span></code></dt><dd><p>Set to ON to force the use of the static libraries.  Default is <code class="docutils literal notranslate"><span class="pre">OFF</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_USE_STATIC_RUNTIME</span></code></dt><dd><p>Set to <code class="docutils literal notranslate"><span class="pre">ON</span></code> or <code class="docutils literal notranslate"><span class="pre">OFF</span></code> to specify whether to use libraries linked
statically to the C++ runtime (&quot;s&quot; tag).  Default is platform dependent.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_USE_DEBUG_RUNTIME</span></code></dt><dd><p>Set to <code class="docutils literal notranslate"><span class="pre">ON</span></code> or <code class="docutils literal notranslate"><span class="pre">OFF</span></code> to specify whether to use libraries linked to the
MS debug C++ runtime (&quot;g&quot; tag).  Default is <code class="docutils literal notranslate"><span class="pre">ON</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_USE_DEBUG_PYTHON</span></code></dt><dd><p>Set to <code class="docutils literal notranslate"><span class="pre">ON</span></code> to use libraries compiled with a debug Python build (&quot;y&quot;
tag).  Default is <code class="docutils literal notranslate"><span class="pre">OFF</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_USE_STLPORT</span></code></dt><dd><p>Set to <code class="docutils literal notranslate"><span class="pre">ON</span></code> to use libraries compiled with STLPort (&quot;p&quot; tag). Default is
<code class="docutils literal notranslate"><span class="pre">OFF</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS</span></code></dt><dd><p>Set to ON to use libraries compiled with STLPort deprecated &quot;native
iostreams&quot; (&quot;n&quot; tag).  Default is <code class="docutils literal notranslate"><span class="pre">OFF</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_COMPILER</span></code></dt><dd><p>Set to the compiler-specific library suffix (e.g. <code class="docutils literal notranslate"><span class="pre">-gcc43</span></code>).  Default is
auto-computed for the C++ compiler in use.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.9: </span>A list may be used if multiple compatible suffixes should be tested for,
in decreasing order of preference.</p>
</div>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_LIB_PREFIX</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.18.</span></p>
</div>
<p>Set to the platform-specific library name prefix (e.g. <code class="docutils literal notranslate"><span class="pre">lib</span></code>) used by
Boost static libs.  This is needed only on platforms where CMake does not
know the prefix by default.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_ARCHITECTURE</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.13.</span></p>
</div>
<p>Set to the architecture-specific library suffix (e.g. <code class="docutils literal notranslate"><span class="pre">-x64</span></code>).
Default is auto-computed for the C++ compiler in use.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_THREADAPI</span></code></dt><dd><p>Suffix for <code class="docutils literal notranslate"><span class="pre">thread</span></code> component library name, such as <code class="docutils literal notranslate"><span class="pre">pthread</span></code> or
<code class="docutils literal notranslate"><span class="pre">win32</span></code>.  Names with and without this suffix will both be tried.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_NAMESPACE</span></code></dt><dd><p>Alternate namespace used to build boost with e.g. if set to <code class="docutils literal notranslate"><span class="pre">myboost</span></code>,
will search for <code class="docutils literal notranslate"><span class="pre">myboost_thread</span></code> instead of <code class="docutils literal notranslate"><span class="pre">boost_thread</span></code>.</p>
</dd>
</dl>
<p>Other variables one may set to control this module are:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_DEBUG</span></code></dt><dd><p>Set to <code class="docutils literal notranslate"><span class="pre">ON</span></code> to enable debug output from <code class="docutils literal notranslate"><span class="pre">FindBoost</span></code>.
Please enable this before filing any bug report.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_REALPATH</span></code></dt><dd><p>Set to <code class="docutils literal notranslate"><span class="pre">ON</span></code> to resolve symlinks for discovered libraries to assist with
packaging.  For example, the &quot;system&quot; component library may be resolved to
<code class="docutils literal notranslate"><span class="pre">/usr/lib/libboost_system.so.1.67.0</span></code> instead of
<code class="docutils literal notranslate"><span class="pre">/usr/lib/libboost_system.so</span></code>.  This does not affect linking and should
not be enabled unless the user needs this information.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_LIBRARY_DIR</span></code></dt><dd><p>Default value for <code class="docutils literal notranslate"><span class="pre">Boost_LIBRARY_DIR_RELEASE</span></code> and
<code class="docutils literal notranslate"><span class="pre">Boost_LIBRARY_DIR_DEBUG</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Boost_NO_WARN_NEW_VERSIONS</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">Added in version 3.20.</span></p>
</div>
<p>Set to <code class="docutils literal notranslate"><span class="pre">ON</span></code> to suppress the warning about unknown dependencies for new
Boost versions.</p>
</dd>
</dl>
<p>On Visual Studio and Borland compilers Boost headers request automatic
linking to corresponding libraries.  This requires matching libraries
to be linked explicitly or available in the link library search path.
In this case setting <code class="docutils literal notranslate"><span class="pre">Boost_USE_STATIC_LIBS</span></code> to <code class="docutils literal notranslate"><span class="pre">OFF</span></code> may not achieve
dynamic linking.  Boost automatic linking typically requests static
libraries with a few exceptions (such as <code class="docutils literal notranslate"><span class="pre">Boost.Python</span></code>).  Use:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">add_definitions(</span><span class="o">${</span><span class="nt">Boost_LIB_DIAGNOSTIC_DEFINITIONS</span><span class="o">}</span><span class="nf">)</span>
</pre></div>
</div>
<p>to ask Boost to report information about automatic linking requests.</p>
</section>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Link to this heading">¶</a></h2>
<p>Find Boost headers only:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">find_package(</span><span class="nb">Boost</span><span class="w"> </span><span class="m">1.36.0</span><span class="nf">)</span>
<span class="nf">if(</span><span class="nb">Boost_FOUND</span><span class="nf">)</span>
<span class="w">  </span><span class="nf">include_directories(</span><span class="o">${</span><span class="nt">Boost_INCLUDE_DIRS</span><span class="o">}</span><span class="nf">)</span>
<span class="w">  </span><span class="nf">add_executable(</span><span class="nb">foo</span><span class="w"> </span><span class="nb">foo.cc</span><span class="nf">)</span>
<span class="nf">endif()</span>
</pre></div>
</div>
<p>Find Boost libraries and use imported targets:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">find_package(</span><span class="nb">Boost</span><span class="w"> </span><span class="m">1.56</span><span class="w"> </span><span class="no">REQUIRED</span><span class="w"> </span><span class="no">COMPONENTS</span>
<span class="w">             </span><span class="nb">date_time</span><span class="w"> </span><span class="nb">filesystem</span><span class="w"> </span><span class="nb">iostreams</span><span class="nf">)</span>
<span class="nf">add_executable(</span><span class="nb">foo</span><span class="w"> </span><span class="nb">foo.cc</span><span class="nf">)</span>
<span class="nf">target_link_libraries(</span><span class="nb">foo</span><span class="w"> </span><span class="nb">Boost</span><span class="o">::</span><span class="nb">date_time</span><span class="w"> </span><span class="nb">Boost</span><span class="o">::</span><span class="nb">filesystem</span>
<span class="w">                          </span><span class="nb">Boost</span><span class="o">::</span><span class="nb">iostreams</span><span class="nf">)</span>
</pre></div>
</div>
<p>Find Boost Python 3.6 libraries and use imported targets:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">find_package(</span><span class="nb">Boost</span><span class="w"> </span><span class="m">1.67</span><span class="w"> </span><span class="no">REQUIRED</span><span class="w"> </span><span class="no">COMPONENTS</span>
<span class="w">             </span><span class="nb">python36</span><span class="w"> </span><span class="nb">numpy36</span><span class="nf">)</span>
<span class="nf">add_executable(</span><span class="nb">foo</span><span class="w"> </span><span class="nb">foo.cc</span><span class="nf">)</span>
<span class="nf">target_link_libraries(</span><span class="nb">foo</span><span class="w"> </span><span class="nb">Boost</span><span class="o">::</span><span class="nb">python36</span><span class="w"> </span><span class="nb">Boost</span><span class="o">::</span><span class="nb">numpy36</span><span class="nf">)</span>
</pre></div>
</div>
<p>Find Boost headers and some <em>static</em> (release only) libraries:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">set(</span><span class="nb">Boost_USE_STATIC_LIBS</span><span class="w">        </span><span class="no">ON</span><span class="nf">)</span><span class="w">  </span><span class="c"># only find static libs</span>
<span class="nf">set(</span><span class="nb">Boost_USE_DEBUG_LIBS</span><span class="w">        </span><span class="no">OFF</span><span class="nf">)</span><span class="w">  </span><span class="c"># ignore debug libs and</span>
<span class="nf">set(</span><span class="nb">Boost_USE_RELEASE_LIBS</span><span class="w">       </span><span class="no">ON</span><span class="nf">)</span><span class="w">  </span><span class="c"># only find release libs</span>
<span class="nf">set(</span><span class="nb">Boost_USE_MULTITHREADED</span><span class="w">      </span><span class="no">ON</span><span class="nf">)</span>
<span class="nf">set(</span><span class="nb">Boost_USE_STATIC_RUNTIME</span><span class="w">    </span><span class="no">OFF</span><span class="nf">)</span>
<span class="nf">find_package(</span><span class="nb">Boost</span><span class="w"> </span><span class="m">1.66.0</span><span class="w"> </span><span class="no">COMPONENTS</span><span class="w"> </span><span class="nb">date_time</span><span class="w"> </span><span class="nb">filesystem</span><span class="w"> </span><span class="nb">system</span><span class="w"> </span><span class="p">...</span><span class="nf">)</span>
<span class="nf">if(</span><span class="nb">Boost_FOUND</span><span class="nf">)</span>
<span class="w">  </span><span class="nf">include_directories(</span><span class="o">${</span><span class="nt">Boost_INCLUDE_DIRS</span><span class="o">}</span><span class="nf">)</span>
<span class="w">  </span><span class="nf">add_executable(</span><span class="nb">foo</span><span class="w"> </span><span class="nb">foo.cc</span><span class="nf">)</span>
<span class="w">  </span><span class="nf">target_link_libraries(</span><span class="nb">foo</span><span class="w"> </span><span class="o">${</span><span class="nt">Boost_LIBRARIES</span><span class="o">}</span><span class="nf">)</span>
<span class="nf">endif()</span>
</pre></div>
</div>
</section>
<section id="boost-cmake">
<span id="id1"></span><h2>Boost CMake<a class="headerlink" href="#boost-cmake" title="Link to this heading">¶</a></h2>
<p>If Boost was built using the boost-cmake project or from Boost 1.70.0 on
it provides a package configuration file for use with find_package's config mode.
This module looks for the package configuration file called
<code class="docutils literal notranslate"><span class="pre">BoostConfig.cmake</span></code> or <code class="docutils literal notranslate"><span class="pre">boost-config.cmake</span></code> and stores the result in
<code class="docutils literal notranslate"><span class="pre">CACHE</span></code> entry <code class="docutils literal notranslate"><span class="pre">Boost_DIR</span></code>.  If found, the package configuration file is loaded
and this module returns with no further action.  See documentation of
the Boost CMake package configuration for details on what it provides.</p>
<p>Set <code class="docutils literal notranslate"><span class="pre">Boost_NO_BOOST_CMAKE</span></code> to <code class="docutils literal notranslate"><span class="pre">ON</span></code>, to disable the search for boost-cmake.</p>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
  <div>
    <h3>Table of Contents</h3>
    <ul>
<li><a class="reference internal" href="#">FindBoost</a><ul>
<li><a class="reference internal" href="#result-variables">Result Variables</a></li>
<li><a class="reference internal" href="#cache-variables">Cache variables</a></li>
<li><a class="reference internal" href="#hints">Hints</a></li>
<li><a class="reference internal" href="#imported-targets">Imported Targets</a></li>
<li><a class="reference internal" href="#other-variables">Other Variables</a></li>
<li><a class="reference internal" href="#examples">Examples</a></li>
<li><a class="reference internal" href="#boost-cmake">Boost CMake</a></li>
</ul>
</li>
</ul>

  </div>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="WriteCompilerDetectionHeader.html"
                          title="previous chapter">WriteCompilerDetectionHeader</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="FindCABLE.html"
                          title="next chapter">FindCABLE</a></p>
  </div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/module/FindBoost.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="FindCABLE.html" title="FindCABLE"
             >next</a> |</li>
        <li class="right" >
          <a href="WriteCompilerDetectionHeader.html" title="WriteCompilerDetectionHeader"
             >previous</a> |</li>
  <li>
    <label class="sidebar-toggle" for="sidebar-check"></label>
  </li>
  <li class="rootlink">
    <img src="../_static/cmake-logo-16.png" width="16" height="16" alt=""/>
    <a href="https://cmake.org/">CMake 4.1.1</a>
    <span class="reldelim1"> &#187;</span>
  </li>
  <li>
    <a href="../index.html">Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" >cmake-modules(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">FindBoost</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
    &#169; Copyright 2000-2025 Kitware, Inc. and Contributors.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3.
    </div>
<script type="text/javascript">
(function() {
  "use strict";
  const hide = () => document.getElementById("sidebar-check").checked = false;
  addEventListener("keydown", e => (e.key === "Escape") && hide());
  addEventListener("click", e => (e.target.tagName === "A") && hide());
  addEventListener("hashchange", hide)
})();
</script>
  </body>
</html>